<?php
/**
 * 
 * 保存后台编辑的留言
 * @author LeoNing
 *
 */
class SaveAsk extends Action {
	/* (non-PHPdoc)
	 * @see Action::execute()
	 */
	public function execute($params) {
		$me = check_login ( ADMIN_LOGIN_PAGE );
		$data ['success'] = false;
		$ask_id = irqst ( 'ask_id' );
		$ask_content = rqst ( 'ask_content' );
		if (empty ( $ask_id )) {
			$data ['msg'] = '你正在编辑未知的留言.';
		} else if (empty ( $ask_content )) {
			$data ['msg'] = '留言不能为空.';
		} else {
			$askM = new PlugAskModel ();
			$rst = $askM->update ( array ('ask_content' => $ask_content ), $ask_id );
			if ($rst !== false) {
				$data ['success'] = true;
			} else {
				$data ['msg'] = '保存留言时出错啦：' . $askM->last_error_msg ();
			}
		}
		return new JsonView ( $data );
	}
}